xen: arm: correctly handle vtimer traps from userspace
authorIan Campbell <ian.campbell@citrix.com>
Mon, 30 Mar 2015 11:12:23 +0000 (12:12 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Tue, 31 Mar 2015 08:42:18 +0000 (09:42 +0100)
commitd306211e2131eb2d160522f21f21fceaa9dd054c
treeb355eb19f7784dee49d57d718fcd6b9b28509065
parent9e1342cf1aabf5841293d32c918f59ffee01ec67
xen: arm: correctly handle vtimer traps from userspace

Previously 32-bit userspace on 32-bit kernel and 64-bit userspace on
64-bit kernel could access these registers irrespective of whether the
kernel had configured them to be allowed to. To fix this:

 - Userspace access to CNTP_CTL_EL0 and CNTP_TVAL_EL0 should be gated
   on CNTKCTL_EL1.EL0PTEN.
 - Userspace access to CNTPCT_EL0 should be gated on
   CNTKCTL_EL1.EL0PCTEN.

When we do not handle an access we now silently inject an undef even
in debug mode since the debugging messages are not helpful (we have
handled the access, by explicitly choosing not to).

The usermode accessibility check is rather repetitive, so a helper
macro is introduced.

Since HSR_EC_CP15_64 cannot be taken from a guest in AArch64 mode
except due to a hardware bug switch the associated check to a BUG_ON
(which will be switched to something more appropriate in a subsequent
patch)

Fix a coding style issue in HSR_CPREG64(CNTPCT) while touching similar
code.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Reviewed-by: Julien Grall <julien.grall@linaro.org>
xen/arch/arm/traps.c
xen/arch/arm/vtimer.c
xen/include/asm-arm/processor.h